package framework.system.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import framework.core.entity.BaseEntity;

/**
 * @ClassName: SysUser 
 * @Description: 系统用户
 * @author: Ching Wang
 * @date 2013-5-3 下午2:37:23 
 *
 */
@Entity
@Table(name = "sys_user")
public class SysUser extends BaseEntity {

	/**
	 * 用户编号
	 */
	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid" ,strategy = "org.hibernate.id.UUIDGenerator")
	@Column(name = "id", nullable = false, length = 36)
	private String id;
	
	/**
	 * 用户姓名
	 */
	@Column(name = "name", nullable = false, length = 100)
	private String name;
	
	/**
	 * 用户帐号
	 */
	@Column(name = "account", nullable = false, length = 20)
	private String account;
	
	/**
	 * 用户密码
	 */
	@Column(name = "password", nullable = false, length = 32)
	private String password;
	
	/**
	 * 邮箱
	 */
	@Column(name = "email", nullable = true, length = 100)
	private String email;
	
	/**
	 * 联系方式
	 */
	@Column(name = "mobile", nullable = true, length = 11)
	private String mobile;
	
	/**
	 * 用户地址
	 */
	@Column(name = "address", nullable = true, length = 200)
	private String address;
	
	/**
	 * 创建时间
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "createDate", nullable = false, updatable = false)
	private Date createDate;
	
	/**
	 * 修改时间
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "modifyDate")
	private Date modifyDate;
	
	/**
	 * 备注信息
	 */
	@Column(name = "remark", length = 4000)
	private String remark;
	
	/**
	 * 用户角色
	 */
	@ManyToMany(targetEntity = SysRole.class, cascade = { CascadeType.MERGE, CascadeType.REFRESH },fetch = FetchType.LAZY)
	@JoinTable(name = "sys_user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") })
	private Set<SysRole> sysRoles;
	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the account
	 */
	public String getAccount() {
		return account;
	}
	/**
	 * @param account the account to set
	 */
	public void setAccount(String account) {
		this.account = account;
	}
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the mobile
	 */
	public String getMobile() {
		return mobile;
	}
	/**
	 * @param mobile the mobile to set
	 */
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}
	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}
	/**
	 * @return the createDate
	 */
	public Date getCreateDate() {
		return createDate;
	}
	/**
	 * @param createDate the createDate to set
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	/**
	 * @return the modifyDate
	 */
	public Date getModifyDate() {
		return modifyDate;
	}
	/**
	 * @param modifyDate the modifyDate to set
	 */
	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}
	/**
	 * @return the remark
	 */
	public String getRemark() {
		return remark;
	}
	/**
	 * @param remark the remark to set
	 */
	public void setRemark(String remark) {
		this.remark = remark;
	}
	/**
	 * @return the sysRoles
	 */
	public Set<SysRole> getSysRoles() {
		return sysRoles;
	}
	/**
	 * @param sysRoles the sysRoles to set
	 */
	public void setSysRoles(Set<SysRole> sysRoles) {
		this.sysRoles = sysRoles;
	}
}